package com.cda.pes.controller;

import com.cda.pes.pojo.Order;
import com.cda.pes.pojo.OrderItem;
import com.cda.pes.service.IOrderService;
import com.cda.pes.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("orders")
public class OrderController extends BaseController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("create")
    public JsonResult<Order> create(Integer aid, Integer[] cids, HttpSession session){
        Integer uid = getuidFromSession(session);
        String username = getUsernameFromSession(session);
        Order data = orderService.create(aid, uid, username, cids);

        return new JsonResult<>(OK,data);
    }

//    @RequestMapping({"","/"})
//    public JsonResult<List<Integer>> findOidByUid(HttpSession session){
//        Integer uid = getuidFromSession(session);
//        List<Integer> data = orderService.findOidByUid(uid);
//        return new JsonResult<List<Integer>>(OK,data);
//    }

}
